package net.xiangcaowuyu.shiro.controller;

import net.xiangcaowuyu.shiro.entity.ShiroUser;
import net.xiangcaowuyu.shiro.service.ShiroUserService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author laughing
 * @date 2020/10/13
 * @site https://www.xiangcaowuyu.net
 */
@RestController
@RequestMapping("user")
public class UserController {

    @Resource
    ShiroUserService shiroUserService;

    /**
     * 查找所有用户
     * @return
     */
    @RequiresPermissions("user:find")
    @RequestMapping("/findAll")
    public List<ShiroUser> findAll() {
        return shiroUserService.findAll();
    }

    /**
     * 查找所有用户
     * @return
     */
    @RequiresPermissions("user:find")
    @RequestMapping("/insert")
    public int save(ShiroUser shiroUser) {
        return shiroUserService.insert(shiroUser);
    }

    /**
     * 查找所有用户
     * @return
     */
    @RequiresPermissions("user:setRole")
    @RequestMapping("/setRole")
    public int setRole(ShiroUser shiroUser) {
        return 0;
    }

}
